<%--

Copyright (C) 2008-2009 Cristian Olaru <colaru@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

--%>
<%@ include file="/common/taglibs.jsp"%>

<div class="hidden">
	<form id="newsletterForm"
		action="http://javaromania.list-manage.com/subscribe/post"
		method="POST">
			<input type="hidden" name="u" value="8ea88774785e1455432f3f3e1" /> 
			<input type="hidden" name="id" value="add0df0df8" /> 
			<input type="hidden" name="MERGE0" id="MERGE0" />
		    <input type="hidden" name="MERGE1" id="MERGE1" /> 
		    <input type="hidden" name="MERGE2" id="MERGE2" />
	</form>
</div>

<div id="side">


	
	<div class="more" style="font-size: 14px;">
	<a href="<c:url value="/forumContent.html"/>">Forum</a> | <a
			href="http://javaromania.blogspot.com">Blog</a> |
		<fmt:bundle basename="ApplicationResources">
			<fmt:message key="side.change.language" />
		</fmt:bundle>
		<a href="<c:url value="/mainContent${application_theme}.html?t=0&request_locale=ro"/>">
		<fmt:bundle basename="ApplicationResources">
			<fmt:message key="side.change.language.ro" />
		</fmt:bundle>
		</a>
		/ 
		<a href="<c:url value="/mainContent${application_theme}.html?t=0&request_locale=en"/>">
		<fmt:bundle basename="ApplicationResources">
			<fmt:message key="side.change.language.en" />
		</fmt:bundle>
		</a>
	</div>

	<br/>

	<authz:authorize ifAnyGranted="ROLE_ANONYMOUS">
		<div class="boxtop"></div>
		<div class="box">
			<h3>NEWSLETTER</h3>
			<ul>
				<li><label for="emailAdress"><strong>Adresa
					Email</strong> <em>(obligatoriu)</em></label><br>
						<input type="text" id="emailAdress" size="25" value=""
							style="width: 100%; max-width: 250px;"></li>
				<li><label for="firstName">Prenume <em>(optional)</em></label><br>
					<input type="text" id="firstName" size="25" value=""
						style="width: 100%; max-width: 250px;"></li>
				<li><label for="lastName">Nume <em>(optional)</em></label><br>
					<input type="text" id="lastName" size="25" value=""
						style="width: 100%; max-width: 250px;"></li>
				<li>
					<fieldset>Format preferat</legend> <input type="radio"
						name="EMAILTYPE" value="html" checked><label
							for="EMAILTYPE_HTML">HTML</label>&nbsp; &nbsp; <input type="radio"
								name="EMAILTYPE" value="text"><label for="EMAILTYPE_TEXT">Text</label>
								<input type="radio" name="EMAILTYPE" value="mobile"><label
									for="EMAILTYPE_MOBILE">Mobile</label></fieldset>
				</li>
				<li><input type="submit"
					onclick="javascript:submitNewsletterForm()"
					value="Aboneaza-ma la lista"></li>
			</ul>

		</div>
		<div class="boxbottom"></div>
	</authz:authorize> 
	
	<br/>
	
	
		<div class="boxtop"></div>
			<div class="box">
				<h3><fmt:bundle basename="ApplicationResources"><fmt:message key="side.your.options" /></fmt:bundle></h3>
				
				<span class="item">
					<a href="editArticleContent${application_theme}.html">
						<strong>
							<fmt:bundle basename="ApplicationResources">
								<fmt:message key="side.new.article" />
							</fmt:bundle>
						</strong>
					</a>
					<br/>
					<fmt:bundle basename="ApplicationResources"><fmt:message key="side.new.article.info" /></fmt:bundle> 
				</span> 
				
				<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ADMIN">
				<span class="item">
					<a href="listArticles${application_theme}.html">
						<strong>
							<fmt:bundle basename="ApplicationResources">
								<fmt:message key="side.edit.article" />
							</fmt:bundle>
						</strong>
					</a>
					<br />
					<fmt:bundle basename="ApplicationResources">
						<fmt:message key="side.edit.article.info" />
					</fmt:bundle> </span> <span class="item last">
					<a href="editUserProfile${application_theme}.html?id=<authz:authentication operation="id"/>">
						<strong>
							<fmt:bundle basename="ApplicationResources">
								<fmt:message key="side.edit.profile" />
							</fmt:bundle>
						</strong>
					</a>
					<br />
					<fmt:bundle basename="ApplicationResources">
						<fmt:message key="side.edit.profile.info" />
					</fmt:bundle> 
				</span>
				</authz:authorize> 
			</div>
		<div class="boxbottom"></div>
		<br />	
	
	
	<authz:authorize ifAnyGranted="ROLE_ADMIN">
		<div class="boxtop"></div>
		<div class="box">
			<h3><fmt:bundle basename="ApplicationResources"><fmt:message key="side.administrative.options" /></fmt:bundle></h3>
			
			<span class="item">
				<a href="applicationConfiguration${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.edit.configuration" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.edit.configuration.info" />
				</fmt:bundle> 
			</span>
			
			<span class="item"> 
				<a href="aprouveArticlesList${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.manage.article" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.manage.article.info" />
				</fmt:bundle> 
			</span> 
			<span class="item"> 
				<a href="aprouveUsersList${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.edit.users" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.edit.users.info" />
				</fmt:bundle> 
			</span> 
			<span class="item"> 
				<a href="aprouveCommentsList${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.manage.comments" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.manage.comments.info" />
				</fmt:bundle> 
			</span>

			<span class="item">
				<a href="categories${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.edit.categories" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.edit.categories.info" />
				</fmt:bundle> 
			</span>

			<span class="item">
				<a href="links${application_theme}.html">
					<strong>
						<fmt:bundle basename="ApplicationResources">
							<fmt:message key="side.edit.links" />
						</fmt:bundle>
					</strong>
				</a>
				<br />
				<fmt:bundle basename="ApplicationResources">
					<fmt:message key="side.edit.links.info" />
				</fmt:bundle> 
			</span>
			
		</div>
		<div class="boxbottom"></div>
		<br />		
	</authz:authorize>
	

		
	<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ANONYMOUS">

			<div class="boxtop"></div>
			<div class="box">
				<h3><fmt:bundle basename="ApplicationResources"><fmt:message key="side.popular.entries" /></fmt:bundle></h3>
				<c:forEach var="article" items="${articlesVoting}" varStatus="rowCounter">
					<c:set var="articleContent">
						<authz:authorize ifAnyGranted="ROLE_ANONYMOUS">
							content_${article.titleLine}_${article.id}.xhtml
						</authz:authorize>
						<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ADMIN">
							getArticleContent.html?id=${article.id}
						</authz:authorize>
					</c:set>
					<a href="<c:out value="${articleContent}"/>" title="${article.overview}"> 
						<c:choose>
							<c:when test="${rowCounter.last}">
								<span class="item last">
							</c:when>
							<c:otherwise>
								<span class="item">
							</c:otherwise>
						</c:choose> 
							<span class="sidedate">
								<fmt:formatNumber maxFractionDigits="1" value="${article.ratingsNumber}" />
								<br />
								<span>
									<img align="top" src="<c:url value="${article.type.urlmin}"/>" 	title="${article.type.name}" />
								</span>
							</span> 
								<strong>${article.title}</strong>
								<br/>
								<div class="sidevote">${article.overview}</div>
							</span>
					</a>
				</c:forEach>
			</div>
			<div class="boxbottom"></div>
			<br />
	</authz:authorize>

	<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ANONYMOUS">
			<div class="boxtop"></div>
			<div class="box">
				<h3><fmt:bundle basename="ApplicationResources"><fmt:message key="side.last.comments" /></fmt:bundle></h3>			
				<ul>
					<c:forEach var="comment" items="${lastComments}" varStatus="rowCounter">
						<li><a title="${comment.nickname} : ${comment.date}" href="getArticleContent.html?id=${comment.article.id}#comments">${comment.nickname} : ${comment.title}</a></li>
					</c:forEach>
				</ul>
			</div>
			<div class="boxbottom"></div>
			<br />
	</authz:authorize>
	
	<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ANONYMOUS">
			
			<div class="boxtop"></div>
			<div class="box">
				<h3><fmt:bundle basename="ApplicationResources"><fmt:message key="side.tags.cloud" /></fmt:bundle></h3>				
				<ul id="xlist" class="xmpl">
					<c:forEach var="tag" items="${allTags}" varStatus="rowCounter">
						<c:if test="${tag[1]>1}">
							<li value="${tag[1]}"><a href="getArticlesByTag.html?tagName=${tag[0]}">${tag[0]}</a></li>
						</c:if>
					</c:forEach>
				</ul>				
				<script type="text/javascript">
					var aLi = $("#xlist>li");
					var iLi = aLi.length;
					$.each(aLi, function(i, o) {
					$(o).attr("title", $(o).text());
					});
					
					$.tagcloud.defaults.sizemin = 8;
					$("#xlist").tagcloud( {
					type :"list",
					sizemin :13
					}).find("li");
				</script>
			</div>
			<div class="boxbottom"></div>
			<br />		
	</authz:authorize>

	<authz:authorize ifAnyGranted="ROLE_USER, ROLE_ANONYMOUS">			
			<div class="boxtop"></div>
			<div class="box">
				<h3>ARHIVE</h3>			
				<ul>
					<li>
						<c:forEach var="archives" items="${archives}" varStatus="rowCounter">
							<a href="getArticlesByDate.html?${archives.key}">${archives.value}</a>
							<c:if test="${!rowCounter.last}"> | </c:if>
						</c:forEach>
					</li>
				</ul>
			</div>
			<div class="boxbottom"></div>
			<br />
	</authz:authorize>
	
	<cache:cache scope="application" time="60" groups="tag_cache" key="jobber">
	<authz:authorize ifAnyGranted="ROLE_ANONYMOUS">
			<div class="boxtop"></div>
			<div class="box">
				<h3>IT JOBS - JOBBER.RO</h3>
				
				<script
					src="http://www.jobber.ro/api/api.php?action=getJobs
					&type=fulltime&category=programatori&count=10&random=0&days_behind=15&response=js"
					type="text/javascript"></script> <script type="text/javascript">
						showJobs('jobber-container', 'jobber-list');
					</script></div>
			<div class="boxbottom"></div>
			<br />
	</authz:authorize> 
	</cache:cache>
	
	<c:forEach var="type" items="${linkTypes}">	
	
		<c:set var="role">
			<c:if test="${type.role==null}">ROLE_ANONYMOUS</c:if>
			<c:if test="${type.role!=null}">${type.role.name}</c:if>
		</c:set>
		
		<authz:authorize ifAnyGranted="${role}">
			<div class="boxtop"></div>
			<div class="box">
				<h3>${type.name}</h3>
				<ul>
					<c:forEach var="category" items="${type.linkCategories}" varStatus="catStatus">
						<li>
							<c:forEach var="link" items="${category.links}" varStatus="status">					
								<a href="${link.url}"
								title="${category.name} : ${link.tooltip}">${link.text}</a> 
								<c:if test="${!status.last}"> | </c:if>
							</c:forEach>
						</li>
						<c:if test="${!catStatus.last}"> <hr style="width: 100%; height: 2px;"/> </c:if>					
					</c:forEach>
				</ul>
			</div>
			<div class="boxbottom"></div>
			<br />
		</authz:authorize>
	</c:forEach>

	<script type="text/javascript">
	
		/*
		 $.ajaxSetup({"error":function(XMLHttpRequest,textStatus, errorThrown) {   
		      alert(textStatus);
		      alert(errorThrown);
		      alert(XMLHttpRequest.responseText);
		  }});
		*/
		  
		$.getJSON("http://localhost:8080/bridge/consoleServlet?command=services",
	        function(data){
	          $.each(data.items, function(i,item){
				if(item.showName == true) {
	        	  $('#side').append(
	        				'<div class="boxtop"></div>'+
	        				'<div class="box">'+
	        					'<h3>' + item.pluginName +
								'</h3>');
	        	  $.get(item.pluginUrl, function(data){
	        		  $('#side').append(data);
	        		 });	
				  $('#side').append('</div><div class="boxbottom"></div>');
				}
				else{
	        	  $.get(item.pluginUrl, function(data){
	        		  $('#side').append(data);
	        		 });	
				}
	          });
	        });
	</script>
</div>


